﻿@model SysCompany
@{
	ViewBag.Title = "公司信息登记表";
}
<div class="ui-widget-header">
	<div style="padding: 5px 10px; font-size: 120%">
		@ViewBag.Title
	</div>
</div>
@using (Ajax.BeginForm(null, null, new AjaxOptions { UpdateTargetId = "Main" }, new {@class="form-edit"}))
{
	<fieldset>
		<legend>
			基本信息
			<a href="#" class="save">[保存]</a>
			@if(Model.ID>0){@Html.ActionLink("[打印]", "Print", new { id = Model.ID, auto = true }, new { @class="print"})}
		</legend>
		<div class="ui-content">
			<div class="ui-cell ui-cell-full">
				@Html.ValidationSummary()
			</div>
			<div class="ui-cell">
				<label>系统编号</label>
				@if(Model.ID>0){@Html.HiddenFor(p=>p.ID)}
				@Html.EditorFor(p => p.SysNo)
			</div>
			<div class="ui-cell ui-cell-full">
				<label>公司名称</label>
				@Html.EditorFor(p => p.Caption)
			</div>
			<div class="ui-cell ui-cell-full">
				<label>公司地址</label>
				@Html.EditorFor(p => p.Address)
			</div>
			<div class="ui-cell">
				<label>大概位置</label>
				@Html.EditorFor(p => p.Attribution)
			</div>
			@*<div class="ui-cell ui-cell-full">
				<label>公司网址</label>
				@Html.EditorFor(p => p.Web)
			</div>*@
			<div class="ui-cell">
				<label>资本结构</label>
				@Html.EditorFor(p => p.Structure)
			</div>
			<div class="ui-cell">
				<label>规模/人数</label>
				@Html.EditorFor(p => p.Employees)
			</div>
			<div class="ui-cell">
				<label>单位性质</label>
				@Html.EditorFor(p => p.Nature)
			</div>
			<div class="ui-cell ui-cell-full">
				<label>公司概况</label>
				@Html.TextAreaFor(p => p.Description)
			</div>
			<div class="ui-cell ui-cell-full">
				<label>备注情况</label>
				@Html.TextAreaFor(p => p.Service)
			</div>
		</div>
	</fieldset>
	if(Model.ID>0)
	{
		<fieldset>
			<legend>
				联系人
				@Html.ActionLink("[添加]","EditContact", new { pid = Model.ID },new { @class="subadd",title="添加 联系人" })
			</legend>
			<div class="ui-content">
				<table>
				@foreach (var item in Model.SysCompanyContact)
				{
		
					<tr>
						<td class="b">@(item.Contact)</td>
						<td class="b">@(item.Telephone)</td>
						<td>
							@Html.ActionLink("[修改]","EditContact", new { wid=item.ID },new { @class="subadd",title="修改 联系人" })
							@Html.ActionLink("[删除]","DelContact", new { wid=item.ID },new { @class="subdel" })
						</td>
					</tr>
				}
				</table>
			</div>
		</fieldset>
		<fieldset>
			<legend>
				招聘信息
				@Html.ActionLink("[添加]","EditEmployee", new { pid = Model.ID },new { @class="subadd",title="添加 招聘信息" })
			</legend>
			<div class="ui-content">
				<table>
				@foreach (var item in Model.SysCompanyEmployee)
				{
					var gender = Common.Dictionary.FirstOrDefault(p => p.Category.Equals("Gender") && p.Worth.Equals(item.Gender));
					var education = Common.Dictionary.FirstOrDefault(p => p.Category.Equals("Education") && p.Worth.Equals(item.Education));
					var salerytype = Common.Dictionary.FirstOrDefault(p => p.Category.Equals("SaleryType") && p.Worth.Equals(item.SaleryType));
					var relaxing = Common.Dictionary.FirstOrDefault(p => p.Category.Equals("WayOfRelaxing") && p.Worth.Equals(item.WayOfRelaxing));
					var working = Common.Dictionary.FirstOrDefault(p => p.Category.Equals("WayOfWorking") && p.Worth.Equals(item.WayOfWorking));
					var householdrequirement = Common.Dictionary.FirstOrDefault(p => p.Category.Equals("HouseholdRequirements") && p.Worth.Equals(item.HouseholdRequirements));
					var agerange = string.IsNullOrWhiteSpace(item.AgeFrom) && string.IsNullOrWhiteSpace(item.AgeTo)?"无要求":
						string.IsNullOrWhiteSpace(item.AgeFrom)?"大于"+item.AgeFrom+"岁":
						string.IsNullOrWhiteSpace(item.AgeTo)?"小于"+item.AgeTo+"岁":
						item.AgeFrom+"-"+item.AgeTo+"岁";
					var workrelax= working==null && relaxing==null?"":
						working==null?relaxing.Caption:
						relaxing==null?working.Caption:
						working.Caption+"+"+relaxing.Caption;
					<tr>
						<td colspan="5" style="border-bottom:1px solid #ccc;">&nbsp;</td>
					</tr>
					<tr>
						<td class="aright">招聘岗位</td>
						<td>@item.Caption</td>
						<td class="aright">招聘人数</td>
						<td>@(string.IsNullOrWhiteSpace(item.MaxMen)?"不限":item.MaxMen)</td>
						<td class="aright" style="width:150px;">
							@Html.ActionLink("[修改]", "EditEmployee", new { wid = item.ID }, new { @class = "subadd",title="修改 招聘信息" })
							@Html.ActionLink("[删除]", "DelEmployee", new { wid = item.ID }, new { @class = "subdel" })
							@Html.ActionLink("[打印]", "PrintEmployee", new { ID = item.ID, auto = true }, new { @class = "print" })
						</td>
					</tr>
					<tr>
						<td class="aright">工作地点</td>
						<td>@item.Workplace</td>
						<td class="aright">发布时间</td>
						<td>@string.Format("{0:yyyy-MM-dd}",item.PublishDate)</td>
						<td></td>
					</tr>
					<tr>
						<td class="aright">性别</td>
						<td>@(gender==null?"不限":gender.Caption)</td>
						<td class="aright">户籍要求</td>
						<td>@(householdrequirement==null?"不限":householdrequirement.Caption)</td>
						<td></td>
					</tr>
					<tr>
						<td class="aright">学历要求</td>
						<td>@(education==null?"不限":education.Caption)</td>
						<td class="aright">综合工资</td>
						<td>@(string.IsNullOrWhiteSpace(item.Salery)?"面议":item.Salery+"元/月")@(salerytype==null?"":"("+salerytype.Caption+")")</td>
						<td></td>
					</tr>
					<tr>
						<td class="aright">试用期</td>
						<td>@(string.IsNullOrWhiteSpace(item.TrailSalery)?"面议":item.TrailSalery+"元/月") (试用期@(string.IsNullOrWhiteSpace(item.TrailMonth)?"面议":item.TrailMonth))</td>
						<td class="aright">年龄要求</td>
						<td>@agerange</td>
						<td></td>
					</tr>
					<tr>
						<td class="aright">工作时间</td>
						<td colspan="3">@(string.IsNullOrWhiteSpace(item.WorkingHours)?"不确定":item.WorkingHours) @workrelax</td>
						<td></td>
					</tr>
					<tr>
						<td class="aright">具体要求</td>
						<td colspan="4">@(string.IsNullOrWhiteSpace(item.JobRequirements)?"面议":item.JobRequirements)</td>
						<td></td>
					</tr>
					<tr>
						<td class="aright">待遇情况</td>
						<td colspan="4">@(string.IsNullOrWhiteSpace(item.SalaryDescription)?"面议":item.SalaryDescription)</td>
						<td></td>
					</tr>
					<tr>
						<td class="aright">工作内容</td>
						<td colspan="4">@(string.IsNullOrWhiteSpace(item.Description)?"面议":item.Description)</td>
					</tr>
				}
				</table>
			</div>
		</fieldset>
	}
}
<script type="text/javascript">
	window.datachanged = false;
	window.uri = "@Url.Action("Edit", new { ID=Model.ID})";
	$("a.save").click(function () { $(this).parents("form").submit() });
	$("a.subdel").click(function () {
		if (confirm("你真的要删除这条数据吗？")) {
			$.post($(this).attr("href"), {}, function (res) {
				//alert(res.msg);
				res.res && $("#Main").load(window.uri);
			})
		}
		return false;
	})
	$("a.subadd").click(function () {
		var ttl=$(this).attr("title");
		$.get($(this).attr("href"), {}, function (data) {
			_d = $("<div id='subMain'></div>").html(data).dialog({
				title: ttl,
				modal: true,
				autoOpen:true,
				width: 550,
				position:['0','center'],
				close: function () { _d.remove(); window.datachanged && $("#Main").load(window.uri); }
			});
		})
		return false;
	});
</script>